<%-- 
    Document   : AllProducts
    Created on : May 12, 2014, 2:19:46 PM
    Author     : Tuan Long
--%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>
    <head>
        <title>I Love Shopping</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <!-- Bootstrap core CSS -->
        <link href="css/bootstrap.min.css" rel="stylesheet">        
        <link href="css/dashboard.css" rel="stylesheet">
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>        
        <script src="js/bootstrap.min.js"></script>
        <script src="js/MyScript.js"></script>

    </head>
    <body>
        <!---- default | inverse: background , fixed | static - top- HEADER--->
        <div class="navbar navbar-default navbar-fixed-top" role="navigation">
            <!----Container---->
            <div class="container">
                <!--nav-header -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">Giza's Assignment</a>
                </div>
                <!--nav-header end-->
                <!--nav-collapse -->
                <div class="navbar-collapse collapse">
                    <ul class="nav navbar-nav">
                        <li class="active"><a href="index.jsp">Home</a></li>

                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">Social Center <b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                <li><a href="#">Facebook</a></li>
                                <li><a href="#">Twitter</a></li>
                                <li><a href="#">Google+</a></li>
                                <li><a href="#">Instagram</a></li>
                                <li class="divider"></li>
                                <li class="dropdown-header">Nav header</li>
                                <li><a href="#">Something else</a></li>
                            </ul>
                        </li>
                        <!--                        <li><a href="#about">About us</a></li>
                                                <li><a href="#contact">Contact us</a></li>-->
                        <li style="padding-top: 8px;">
                            <input type="text" placeholder="Search.." class="form-control" />
                        </li>
                    </ul>

                    <ul class="nav navbar-nav navbar-right">
                        <c:choose>
                            <c:when test="${sessionScope.online != null}">
                                <li style="padding-top: 13px;">Welcome, ${sessionScope.online.fullname}</li>
                                </c:when>
                                <c:when test="${sessionScope.online == null}">
                                <li class="dropdown" >
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Login<b class="caret"></b></a>
                                    <ul class="dropdown-menu" style="padding-left: 3px; padding-right: 3px;">                                        
                                        <form class="form-signin" role="form" action="Login.me" method="post">                                    
                                            <input type="text" class="form-control" placeholder="Username" name="username" required autofocus>
                                            <input type="password" class="form-control" placeholder="Password" name="password" required>                                    
                                            <button class="btn btn-primary btn-block" type="submit">Sign in</button>
                                        </form>
                                    </ul>
                                </li>
                                <li><a href="#">Register</a></li>
                                </c:when>
                            </c:choose>

                    </ul>
                </div>
                <!--nav-collapse end -->
            </div>
            <!----Container end---->
        </div>
        <!---HEADER END-->

        <!---Container---->
        <div class="container-fluid">
            <div class="row">
                <!---SIDEBAR--->
                <div class="col-sm-3 col-md-2 sidebar">
                    <ul class="nav nav-sidebar">
                        <li class="active"><a href="AllProducts.me">All Products</a></li>
                        <li><a href="#">Your Cart</a></li>                        
                    </ul>
                </div>
                <!---SIDEBAR END--->
                <!----WRAPPER CONTENT---->
                <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                    <!---Product images-->
                    <h1 class="page-header">All Products</h1>
                    <div class="row placeholders">
                        <c:forEach var="p" items="${list}">
                            <div class="col-xs-6 col-sm-3 placeholder">
                                <a href="ProductDetail.me?ProductID=${p.id}"><img src="${p.imgURL}" class="img-responsive" style="width: 195px;height: 195px;" ></a>
                                <h4>${p.name} <code>$${p.price}</code></h4>
                                <a href="CartOnline.me?ProductID=${p.id}"><button type="button" class="btn btn-warning">Buy Now</button></a>
                            </div>
                        </c:forEach>
                    </div>                    
                    <div style="text-align: center;">                         
                        <c:if test="${currentPage ne 1}">
                            <a href="AllProducts.me?page=${currentPage-1}">Previous</a>
                        </c:if>
                        <c:forEach begin="1" end="${no_page}" var="i">
                            <c:choose>
                                <c:when test="${currentPage eq i}">
                                    <a  style="color:red;">${i}</a>
                                </c:when>
                                <c:otherwise>
                                    <a href="AllProducts.me?page=${i}">${i}</a>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                        <c:if test="${currentPage lt no_page}">
                            <a href="AllProducts.me?page=${currentPage+1}">Next</a>
                        </c:if>
                    </div>
                    <!---Product images end-->
                </div>

                <!----WRAPPER CONTENT END---->
            </div>            
        </div>
        <!---Container END---->
        <!-- FOOTER -->
        <div class="container">
            <footer style="text-align: center;">
                <p class="pull-right scrollTop"><a href="#">Back to top</a></p>
                <p>&copy; 2014 Developed & Design By Giza &middot; <a href="https://www.facebook.com/">Facebook</a> &middot;</p>
            </footer>
        </div>
        <!-- FOOTER END -->

    </body>
</html>
